//
//  BaseNavigationController.swift
//  edu
//
//  Created by karlzhou on 15/10/29.
//  Copyright (c) 2015年 karlzhou. All rights reserved.
//

import UIKit

class BaseNavigationController: UINavigationController {
    
    override init(rootViewController: UIViewController){
        super.init(rootViewController: rootViewController)
    }
    
    
    override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?){
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    override func viewDidLoad() {
        super.viewDidLoad()
        
        print("BaseNavigationController address:\(self.hashValue)")
        self.navigationBar.backgroundColor=UIColor.greenColor()
        //initRight()
        //initLeft()
        //self.
        // Do any additional setup after loading the view.
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        
    }
    
    override func pushViewController(viewController: UIViewController, animated: Bool) {
        if(self.viewControllers.count>0){
            viewController.navigationItem.leftBarButtonItem = UIBarButtonItem.itemWithImage("ico_bar_back", highImage: "ico_bar_back_pressed", target: self, action: "goback")
        }
        super.pushViewController(viewController, animated: animated)
        
        
    }
    
    func goback(){
        print("click back")
        self.popViewControllerAnimated(true)
    }
 
    
    
    
}
